package cate.game.role.farm;

import cate.common.game.GameCollection;
import cate.game.GameBody;
import cate.game.role.farm.cross_boss.MyCrossBossPO;
import cate.game.role.farm.endless.MyEndlessPO;
import cate.game.role.Role;
import cate.game.role.RolePart;
import cate.game.role.farm.adventure.Adventure;
import cate.game.role.farm.dailyfb.MyDailyFb;
import cate.game.role.farm.forbidden.MyForbiddenZone;
import cate.game.role.farm.guildBoss.MyGuildBossPO;
import cate.game.role.farm.guildFairyland.MyGuildFairylandPO;
import cate.game.role.farm.island.Island;
import cate.game.role.farm.pk.MyPkPO;
import cate.game.role.farm.rank.RoleRank;
import cate.game.role.farm.spicefb.SpiceFb;
import cate.game.role.farm.tower.Tower;
import cate.game.role.farm.udgpalace.MyUdgPalace;
import cate.game.role.merge.IRoleMergeSettle;
import cate.game.role.farm.herotrain.TrainHeroFight;
import cp.solution.util.time.TimeCostRecord;
import easy.java.dev.note.NoteField;
import org.springframework.data.mongodb.core.mapping.Document;

@Document(GameCollection.NAME_ROLE_FARM)
public class RoleFarm extends RolePart implements IRoleMergeSettle {
    @NoteField(value = "主线")
    public Adventure adventure;

    @NoteField(value = "美食神殿")
    public Tower tower;

    @NoteField(value = "公会BOSS")
    public MyGuildBossPO guildBoss;

    @NoteField(value = "迷失神庙")
    public Island island;

    @NoteField(value = "香料副本")
    public SpiceFb spiceFb;

    @NoteField(value = "排行榜")
    public RoleRank rank;

    @NoteField(value = "日常副本")
    public MyDailyFb dailyFb;

    @NoteField(value = "种族禁地（原图腾圣殿）")
    public MyForbiddenZone forbidden;

    @NoteField(value = "切磋")
    public MyPkPO pk;

    @NoteField(value = "无尽轮回")
    public MyEndlessPO endless;

    @NoteField(value = "英雄升星战斗")
    public TrainHeroFight trainHeroFight;

    @NoteField("地宫")
    public MyUdgPalace udgPalace;

    @NoteField("公会秘境")
    public MyGuildFairylandPO guildFairyland;
    @NoteField("跨服BOSS")
    public MyCrossBossPO crossBoss;

    public RoleFarm() {

    }

    public RoleFarm(Role role) {
        super(role);
    }

    @Override
    public void initialize(Role role) {
        super.initialize(role);
        if (adventure == null) {
            adventure = new Adventure();
        }
        adventure.initialize(role);
        if (tower == null) {
            tower = new Tower();
        }
        tower.initialize(role);
        if (island == null) {
            island = new Island();
        }
        island.initialize(role);
        if (spiceFb == null) {
            spiceFb = new SpiceFb();
        }
        spiceFb.initialize(role);
        if (rank == null) {
            rank = new RoleRank();
        }
        rank.initialize(role);
        if (dailyFb == null) {
            dailyFb = new MyDailyFb();
        }
        dailyFb.initialize(role);
        if (forbidden == null) {
            forbidden = new MyForbiddenZone();
        }
        forbidden.initialize(role);
        if (pk == null) {
            pk = new MyPkPO();
        }
        pk.initialize(role);
        if (guildBoss == null) {
            guildBoss = new MyGuildBossPO();
        }
        guildBoss.initialize(role);
        if (endless == null) {
            endless = new MyEndlessPO();
        }
        endless.initialize(role);
        if(trainHeroFight == null){
            trainHeroFight = new TrainHeroFight();
        }
        trainHeroFight.initialize(role);
        if (udgPalace == null) {
            udgPalace = new MyUdgPalace();
        }
        udgPalace.initialize(role);
        if (guildFairyland == null) {
            guildFairyland = new MyGuildFairylandPO();
        }
        guildFairyland.initialize(role);
        if (crossBoss == null) {
            crossBoss = new MyCrossBossPO();
        }
        crossBoss.initialize(role);
    }

    @Override
    public void onDaySpan(boolean silence) {
        //有开服天数相关的功能开启
        checkOpen();
        tower.onDaySpanSafe(silence);
        island.onDaySpanSafe(silence);
        spiceFb.onDaySpanSafe(silence);
        rank.onDaySpanSafe(silence);
        adventure.onDaySpanSafe(silence);
        dailyFb.onDaySpanSafe(silence);
        forbidden.onDaySpan(silence);
        guildBoss.onDaySpan();
        endless.onDaySpanSafe(silence);
        udgPalace.onDaySpanSafe(silence);
        crossBoss.onDaySpan(silence);
    }

    @Override
    public void onWeekSpan(boolean silence) {
        forbidden.onWeekSpan(silence);
    }

    public void checkOpen() {
        adventure.checkOpen();
        tower.checkOpen();
        spiceFb.checkOpen();
        island.checkOpen();
        rank.checkOpen();
        dailyFb.checkOpen();
        forbidden.checkOpen();
        guildBoss.checkOpen();
        endless.checkOpen();
        forbidden.checkOpen();
        udgPalace.checkOpen();
        guildFairyland.checkOpen();
        crossBoss.checkOpen();
    }

    @Override
    public void onEnter() {
        checkOpen();
        adventure.onEnter();
        tower.onEnter();
        guildBoss.onEnter();
        spiceFb.onEnter();
        forbidden.onEnter();
        pk.onEnter();
        island.onEnter();
        dailyFb.onEnter();
        endless.onEnter();
        udgPalace.onEnter();
        guildFairyland.onEnter();
    }

    @Override
    public void onMergeSettle(GameBody game, TimeCostRecord tcr) {
        endless.onMergeSettle();
    }

    public void tick() {

    }
}
